import request from '~/utils/resquest'

//  设备分类
export const getNodeByParentCode = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-system/deviceCategory/getNodeByParentCode',
    method: 'GET',
    params
  })
}

//  所属设施
export const selectBoxListByKey = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-assets/distribution/selectBoxListByKey',
    method: 'GET',
    params
  })
}

//  设备管理-列表
export const deviceListGet = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-monitor/hardware/list',
    method: 'GET',
    params
  })
}

//  设备管理-新增
export const deviceAdd = <T>(data: T) => {
  return request({ url: '/api/gxsaas-monitor/hardware/add', method: 'POST', data })
}

//  设备管理-编辑
export const deviceUpdate = <T>(data: T & { id?: string }) => {
  return request({ url: `/api/gxsaas-monitor/hardware/update?id=${data.id}`, method: 'PUT', data })
}

//  设备管理-品牌
export const getTenantBrandList = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-system/deviceBrand/getHardwareBrandList',
    method: 'GET',
    params
  })
}

//  设备管理-型号
export const getTenantModelList = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-system/deviceModel/getHardwareModelList',
    method: 'GET',
    params
  })
}

//  设备管理-配电设施
export const selectBoxListByName = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-assets/distribution/selectBoxListByName',
    method: 'GET',
    params
  })
}

//  设备管理-删除
export const deviceRemove = <T>(params: T) => {
  return request({ url: '/api/gxsaas-monitor/device/remove', method: 'POST', params })
}

//  设备管理-详情
export const deviceView = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-monitor/device/view',
    method: 'GET',
    params
  })
}

// 设备管理-导出
export const deviceExport = <T>(payload: T) =>
  request({
    url: '/api/gxsaas-monitor/device/export',
    method: 'get',
    responseType: 'blob',
    ...payload
  })

//  设备管理-参数详情
export const viewByDeviceIdGet = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-monitor/hardware/param/viewByDeviceId',
    method: 'GET',
    params
  })
}

//  设备管理-连接参数修改
export const updateConnectionPut = <T>(params: T & { id?: string }) =>
  request({
    url: `/api/gxsaas-monitor/hardware/param/update/connection/${params.id}`,
    method: 'put',
    data: params
  })

//  设备管理-工作参数修改
export const updateWorkPut = <T>(params: T & { id?: string }) =>
  request({
    url: `/api/gxsaas-monitor/hardware/param/update/work/${params.id}`,
    method: 'put',
    data: params
  })

//  设备管理-回路参数修改
export const updateLoopPut = <T>(params: T & { id?: string; list: any }) =>
  request({
    url: `/api/gxsaas-monitor/hardware/param/update/loop/${params.id}`,
    method: 'put',
    data: params.list
  })

//  设备管理-警报参数修改
export const updateAlarmPut = <T>(params: T & { id?: string }) =>
  request({
    url: `/api/gxsaas-monitor/hardware/param/update/alarm/${params.id}`,
    method: 'put',
    data: params
  })

//  设备管理-事件参数修改
export const updateEventPut = <T>(params: T & { id?: string; list: any }) =>
  request({
    url: `/api/gxsaas-monitor/hardware/param/update/event/${params.id}`,
    method: 'put',
    data: params.list
  })

//  设备管理-其他参数修改
export const updateOtherPut = <T>(params: T & { id?: string }) =>
  request({
    url: `/api/gxsaas-monitor/hardware/param/update/other/${params.id}`,
    method: 'put',
    data: params
  })

//  设备管理-查询监控箱下发指令
export const getIssueCommandGet = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-monitor/hardware/getIssueCommand',
    method: 'GET',
    params
  })
}

//  设备管理-查询监控箱查询指令
export const getQueryCommandGet = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-monitor/hardware/getQueryCommand',
    method: 'GET',
    params
  })
}
